﻿using System.Collections.Generic;
using System.ComponentModel;
using Sparkle.Hosting;

namespace Sparkle.Wpf.Demo.UI
{
    public class BaseController<T> : IViewModel<T>, INotifyPropertyChanged
        where T : class , IModel
    {
        #region IViewModel Members

        private T _t;

        public virtual T Model
        {
            get { return _t; }
            set
            {
                _t = value ;
                OnPropertyChanged("Model");
            }
        }

        #endregion

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged == null) return;

            var e = new PropertyChangedEventArgs(propertyName);

            PropertyChanged(this, e);

        }


        public event PropertyChangedEventHandler PropertyChanged;
    }
}